package com.jotta.client.data;

import com.jotta.client.R;
import com.jotta.client.utility.Utility;

import java.util.Date;

public class FileInfo extends ItemInfo {

	protected int currentRevionsNumber;
	protected String pathOfParentFolder;
	protected String pathOfItem;
	protected long fileSize;
	protected String mimeType;
	protected TypeOfFile typeOfFile = TypeOfFile.UNKNOW;
    protected FileState state;
    protected Date deleted = null;

	public FileInfo() {
		super();
		setType(TypeOfItem.FILE);
	}
	
	/**
	 * @param currentRevionsNumber
	 *            the currentRevionsNumber to set
	 */
	public void setCurrentRevionsNumber(int currentRevionsNumber) {
		this.currentRevionsNumber = currentRevionsNumber;
	}

	/**
	 * @return the currentRevionsNumber
	 */
	public int getCurrentRevionsNumber() {
		return currentRevionsNumber;
	}

	/**
	 * @param pathOfItem
	 *            the pathOfItem to set
	 */
	public void setPathOfItem(String pathOfItem) {
		this.pathOfItem = pathOfItem;
	}

	/**
	 * @param mimeType the mimeType to set
	 */
	public void setMimeType(String mimeType) {
		this.mimeType = mimeType;
	}

	/**
	 * @return the mimeType
	 */
	public String getMimeType() {
		return mimeType;
	}

	/**
	 * @return the download path of item
	 */
	public String getDownloadPathOfItem() {
		return pathOfItem + "?mode=bin";
	}

	/**
	 * @return the server path of item
	 */
	public String getServerPathOfItem() {
		return pathOfItem;
	}

	/**
	 * @return the local path of item
	 */
	public String getLocalPathOfItem() {
		return Utility.convertServer2LocalFolder(pathOfItem);
	}

	/**
	 * @param pathOfParentFolder the pathOfParentFolder to set
	 */
	public void setPathOfParentFolder(String pathOfParentFolder) {
        this.pathOfParentFolder = pathOfParentFolder;
    }


	/**
	 * @return the pathOfParentFolder
	 */
	public String getPathOfParentFolder() {
		return pathOfParentFolder;
	}


	/**
	 * @param fileSize
	 *            the fileSize to set
	 */
	public void setFileSize(long fileSize) {
		this.fileSize = fileSize;
		String sizeRepresentation = Utility
				.convertToStringRepresentation(fileSize);
		setDescription(sizeRepresentation);
	}

	/**
	 * @return the fileSize
	 */
	public long getFileSize() {
		return fileSize;
	}

	/**
	 * @param typeOfFile
	 *            the typeOfFile to set
	 */
	public void setTypeOfFile(TypeOfFile typeOfFile) {
		this.typeOfFile = typeOfFile;
	}

	/**
	 * @return the typeOfFile
	 */
	public TypeOfFile getTypeOfFile() {
		return typeOfFile;
	}

    public FileState getState() {
        return state;
    }

    public void setState(FileState state) {
        this.state = state;
    }

    public Date getDeleted() {
        return deleted;
    }

    public void setDeleted(Date deleted) {
        this.deleted = deleted;
    }

    @Override
	public int getImageResourceId() {
		int code = R.drawable.unknown;
		if (typeOfFile == TypeOfFile.MUSIC)
			code = R.drawable.music;
		else if (typeOfFile == TypeOfFile.PDF)
			code = R.drawable.pdf;
		else if (typeOfFile == TypeOfFile.PICTURE)
			code = R.drawable.picture;
		else if (typeOfFile == TypeOfFile.PRESENTATION)
			code = R.drawable.presentation;
		else if (typeOfFile == TypeOfFile.RICHTEXT)
			code = R.drawable.rich_text;
		else if (typeOfFile == TypeOfFile.SPREADSHEET)
			code = R.drawable.spreadsheet;
		else if (typeOfFile == TypeOfFile.TEXT)
			code = R.drawable.text;
		else if (typeOfFile == TypeOfFile.VIDEO)
			code = R.drawable.video;
		else if (typeOfFile == TypeOfFile.WORD)
			code = R.drawable.word;
		else if (typeOfFile == TypeOfFile.XML)
			code = R.drawable.xml;
		else if (typeOfFile == TypeOfFile.ZIP)
			code = R.drawable.zip;
		else if (typeOfFile == TypeOfFile.UNKNOW)
			code = R.drawable.unknown;
		return code;
	}
}
